import os.path, pygame

class aimer:
    def __init__(self, game_logic):
        self.game_logic = game_logic
        #set up aimer
        self.playerimg = pygame.image.load(os.path.join("data", "player1.png"))
        self.aimer_surf = pygame.Surface((32, 32))
        self.aimer_surf.blit(self.playerimg, self.playerimg.get_rect(), pygame.Rect(32,32,32,32))
        self.aimer_surf.set_colorkey((255, 0, 255))
        self.aimer_rect = self.aimer_surf.get_rect()
        
        self.image = self.aimer_surf
        self.rect = self.aimer_rect
    
    def update(self):
        if not self.game_logic.local_player.tank.alive:
            self.image = pygame.Surface((1, 1))
            self.image.set_alpha(0)
            self.rect = self.image.get_rect()
            return
        self.image = self.aimer_surf
        self.rect = self.aimer_rect
        (x, y) = pygame.mouse.get_pos()
        x+= self.game_logic.screen_left
        y+= self.game_logic.screen_top
        self.rect.center = (x, y)
